<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="zh-CN">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>TOP标签</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
</head>
<body>

<table width="100%" height="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#012849">
<tr>
<td height="434" valign="top" bgcolor="#4484C1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr><td height="25" align="center" bgcolor="#014075">
		<table width="96%" border="0" cellspacing="0" cellpadding="0"><tr><td width="60%" align="center">每个K宝价格(K币)</td><td width="40%" align="center">挂单数量(K宝)</td></tr></table>
	</td></tr>
</table>

	<div id="top-sell"></div><!-- #top-sell -->		          

          
<table width="50%" border="0" cellspacing="0" cellpadding="0">
	<tr><td height="7"></td></tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr><td height="2"bgcolor="3676B4"></td></tr>
</table>
<table width="50%" border="0" cellspacing="0" cellpadding="0">
	<tr><td height="7"></td></tr>
</table>
            
	<div id="top-buy"></div><!-- #top-buy --> 

<table width="50%" border="0" cellspacing="0" cellpadding="0">
	<tr><td height="7"></td></tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr><td height="25" align="center" bgcolor="#014075"><span class="blue1">交易说明</span></td></tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="120" align="center" bgcolor="#3676B4"><table width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>
<div id="loading">加载中。。。加载中。。。<br /></div>
        个人交易以K币作流通货币，以K宝<br />
          为交易对象，约定一个K宝为最小交易<br />
          单位。同时称一个K宝为一手。<br />
          <span class="yellow">交易风险自负，买卖均为玩家行为！</span></td>
      </tr>
    </table></td>
  </tr>
</table>
</td>
</tr>
</table>
          

<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	getTop();
	var iTime = setInterval(getTop, 5000);
	
	// 试用JSON传输数据，修正IE6下jQuery解析XML的错误
	function getTop(){
		$.post("bg-top-json.php", {
			action: 'getTop'
			}, function(data, textStatus){
				//alert( data );
				addMsg( data );
			}, 'json');
	} //END func getTop()

	function addMsg(data){
		$("#top-sell").empty();
		$.each(data['sell'], function(i,n){
			if(i%2 == 1) {
				var msg = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr bgcolor=\"#3676B4\"><td width=\"13%\" height=\"23\" class=\"yellow\">卖"
					+(i+1)+"</td><td width=\"51%\" align=\"center\">"
					+n['price']+"K币</td><td width=\"36%\" align=\"center\">"
					+n['num']+"手</td></tr></table>";
			}else
			var msg = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"13%\" height=\"23\" class=\"yellow\">卖"
						+(i+1)+"</td><td width=\"51%\" align=\"center\">"
						+n['price']+"K币</td><td width=\"36%\" align=\"center\">"
						+n['num']+"手</td></tr></table>";
			$("#top-sell").prepend( msg );
		});
		//$("#top-sell > table:odd").attr("bcolor","red"); 
		//alert( $("#top-sell tr:odd").html() );
		//.attr("bgcolor","#3676b4"); 

		var j = 5;
		$("#top-buy").empty();
		$.each(data['buy'], function(i,n){
			if(i%2 == 1) {
				var msg = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr bgcolor=\"#3676B4\"><td width=\"13%\" height=\"23\" class=\"yellow\">买"
					+j+"</td><td width=\"51%\" align=\"center\">"
					+n['price']+"K币</td><td width=\"36%\" align=\"center\">"
					+n['num']+"手</td></tr></table>";
			}else
			var msg = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"13%\" height=\"23\" class=\"yellow\">买"
						+j+"</td><td width=\"51%\" align=\"center\">"
						+n['price']+"K币</td><td width=\"36%\" align=\"center\">"
						+n['num']+"手</td></tr></table>";
			$("#top-buy").prepend( msg );
			j--;
		});
		
	} //END func addMsg

$("#loading").ajaxStart(function(){ $(this).show(); }); 
$("#loading").ajaxStop(function(){ $(this).hide(); }); 
	
});
</script>
</body></html>